import React, { Component } from 'react'
import { withRouter } from 'react-router-dom';

class Header extends Component {

    back = () => {
        this.props.history.goBack();
    }

    
    forward = () => {
        this.props.history.goForward()
    }


    render() {
        return (
        <div className="page-header">
            <h2>React Router Demo</h2>
            <button onClick={this.back}>返回</button>
            <button onClick={this.forward}>前进</button>
        </div>
        );
    }

}

//withRouter可以加工 一般组件，让一般组件具备路由组件所具备的功能
//withRouter返回的值是一个新组件
export default withRouter(Header);
